package zdream.pmfield.stage.action;

import zdream.pmfield.stage.object.ObjectOnSeat;
import zdream.pmfield.stage.object.Seat;

/**
 * @author Zdream
 * @date 2023-11-30
 * @since 0.0.1
 */
public class MovementAction extends StageAction {
	public ObjectOnSeat target;
	public Seat from, to;
	public int innerId = -1;

	@Override
	public int getInnerId() {
		return innerId == -1 ? (innerId = target.stage.getNextIdAndIncrease()) : innerId;
	}

	@Override
	public boolean isForMovement() {
		return true;
	}

	@Override
	public MovementAction asMovement() {
		return this;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder(64);

		if (target == null) {
			builder.append("???");
		} else if (target.isFoe()) {
			target.asFoe().appendStringWithoutHp(builder);
		} else {
			builder.append("???");
		}

		builder.append(' ').append("将从").append(' ');
		if (from == null) {
			builder.append("???");
		} else {
			from.appendStringWithoutFoe(builder);
		}

		builder.append(' ').append("移动到").append(' ');
		if (to == null) {
			builder.append("???");
		} else {
			to.appendStringWithoutFoe(builder);
		}

		return builder.toString();
	}
}
